package app.models;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @author Douglas Fernandes
 * @since 22/11/2013
 */

@Entity
@Table(name = "ESPECIALIDADE")
public class Especialidade implements Pojo {
	
	private static final long serialVersionUID = 9190567574802929873L;
	
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID")
	private Long id;
	
	@NotNull(message = "{nome.empty}")
	@Column(name = "NOME", columnDefinition = "varchar(50)")
	private String nome;
	
	@NotNull(message = "{descricao.empty}")
	@Column(name = "DESCRICAO", columnDefinition = "varchar(150)")
	private String descricao;
	
	@Min(value = 1, message = "{valor.empty}")
	@Column(name = "VALOR", columnDefinition = "double")
	private Double valor;
	
	@NotNull(message = "{quantidadeMaximaPacientes.empty}")
	@Column(name = "QTD_MAXIMA_CONSULTAS", columnDefinition = "integer")
	private Integer qtdMaximaPacientesPorHora;

	@Transient
	private String valorString;
	
	public void setId(Long id) {
		this.id = id;
	}

	public String getValorString() {
		return valorString;
	}

	public void setValorString(String valorString) {
		this.valorString = valorString;
	}

	public Long getId() {
		return id;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getNome() {
		return nome;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setValor(Double valor) {
		this.valor = valor;
	}

	public Double getValor() {
		return valor;
	}

	public Integer getQtdMaximaPacientesPorHora() {
		return qtdMaximaPacientesPorHora;
	}

	public void setQtdMaximaPacientesPorHora(Integer qtdMaximaPacientesPorHora) {
		this.qtdMaximaPacientesPorHora = qtdMaximaPacientesPorHora;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Especialidade other = (Especialidade) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}
